/**
 *
 * Copyright 2015 RSVP Technologies Inc. All rights reserved.
 * User.java
 *
 */
package com.gfinal.tuling;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.gfinal.util.RandomTool;

/**
 * 用户
 * 
 * @author Gao Yudong (gyd@nbicc.com)
 * @date 2015-3-9
 */
public class User implements Serializable {
	private static final long serialVersionUID = -5002801456190120463L;

	/**
	 * 用户ID，上下文时必须
	 */
	private String userId = null;

	/**
	 * 位置信息
	 */
	private String loc = null;

	/**
	 * 经度信息 东经116.234632（小数点后保留6位），需要写为116234632
	 */
	private long lon = 0;

	/**
	 * 纬度信息 北纬40.234632（小数点后保留6位），需要写为40234632
	 */
	private long lat = 0;

	/**
	 * 问题内容
	 */
	private String info = null;

	public User() {
		userId = RandomTool.generateString(9);
	}

	public String getInfo() throws UnsupportedEncodingException {
		return URLEncoder.encode(info, "utf-8");
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getUserId() {
		return userId;
	}

	public void setLoc(String loc) {
		this.loc = loc;
	}

	public String getLoc() throws UnsupportedEncodingException {
		if(loc != null)
			return URLEncoder.encode(loc, "utf-8");
		else
			return null;
	}

	public long getLon() {
		return lon;
	}

	public long getLat() {
		return lat;
	}

	public void setLon(long lon) {
		this.lon = lon;
	}

	public void setLat(long lat) {
		this.lat = lat;
	}

}
